|
|
|
|
|
|
|
You can easily modify the layout and the contents of the log reports. You need only change a few lines of code in the LogError method. |
|
|
|
|
|
|
|
|
Adding a Module Trace to the Error Handler |
|
|
|
|
|
|
|
|
The final touch to add to your error handler library is the option to keep track of and print a module trace. A module trace keeps track of all the modules that have been called and the order in which they were invoked. This can be very valuable when you're debugging programs. Often, a routine works just fine when it is called from one module, but it reports errors if called from another module. When errors occur, it's handy to have a module trace to look through to help find the source of your problems. |
|
|
|
|
|
|
|
|
We implement our module trace routines as a new objclass object in the prjErrHandler project. Reload the ActiveX DLL project and add a new class module to the project. Set its Name property to TraceObject and keep its Instancing property set to the default, 5 MultiUse. |
|
|
|
|
|
|
|
|
You need two new properties for this object (TraceFileName and TraceFlag) and a handful of new Public methods: |
|
|
|
|
|
|
|
|
·Push adds a sub or function name to the call list. |
|
|
|
|
|
|
|
|
·Pop removes a sub or function name from the call list. |
|
|
|
|
|
|
|
|
·List returns an array of all the names on the call list. |
|
|
|
|
|
|
|
|
·Dump writes the complete call list to a disk file. |
|
|
|
|
|
|
|
|
·Show displays the complete call list in a message box. |
|
|
|
|
|
|
|
|
·Clear resets the call list. |
|
|
|
|
|
|
|
|
First, add the code in Listing 14.30 to the general declarations area of the class module. |
|
|
|
|
|
|
|
|
Listing 14.30. Declaring the TraceObject variables. |
|
|
|
|
|
|
|
|
Option Explicit
'
' local property storage
Private trcFileName As String
Private trcFlag As Boolean
'
' internal variables
Private trcStack() As String
Private trcPointer As Long |
|
|
|
|
|